<?php
// 应从数据库或配置文件中获取
$style = "json";//目前只支持json格式
$func = dowith_sql($_REQUEST['func']);
$partner = dowith_sql($_REQUEST['partner']);//合作方
$pass = dowith_sql($_REQUEST['pass']);//密码
$string = iconv('utf-8','utf-8', dowith_sql($_REQUEST['content']));//请求内容
$content = base64_encode(trim($string));
$verify = md5($partner.$content.$pass);
$PostData = array(
   "style" => $style,  
   "func" => $func, 
   "partner" => $partner,
   "content" => $content,
   "verify" => $verify,
);
$url="http://www.daoda100.com/api/jiekou.php"; 
$param= $PostData;
   //post方式发送
    $oCurl = curl_init();
	 if (stripos($url, "https://") !== FALSE) {
		curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
	 }
	 $strPOST = http_build_query($param);
	 curl_setopt($oCurl, CURLOPT_URL, $url);      
	 curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
	 curl_setopt($oCurl, CURLOPT_POST, true);
     curl_setopt($oCurl, CURLOPT_POSTFIELDS, $strPOST);
     curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
     $sContent = curl_exec($oCurl);
     $aStatus = curl_getinfo($oCurl);
     curl_close($oCurl);

$array=array('content' =>  $content,'result' =>  $sContent, 'verify' => $verify,'status'=> 'OK');
exit(json_encode($array));

function dowith_sql($str)
{
   $str = str_replace("and","",$str);
   $str = str_replace("execute","",$str);
   $str = str_replace("update","",$str);
   $str = str_replace("count","",$str);
   $str = str_replace("chr","",$str);
   $str = str_replace("mid","",$str);
   $str = str_replace("master","",$str);
   $str = str_replace("truncate","",$str);
   $str = str_replace("char","",$str);
   $str = str_replace("declare","",$str);
   $str = str_replace("select","",$str);
   $str = str_replace("create","",$str);
   $str = str_replace("delete","",$str);
   $str = str_replace("insert","",$str);
   $str = str_replace("'","",$str);
   $str = str_replace("=","",$str);
   return $str;
}